package 作业.sxt;

import java.io.*;
import java.util.*;

public class PrinceDate {

	public static void main(String[] args) {

		try {
			File file = new File("C:\\Users\\苹果芒果火龙果\\Desktop\\Price.txt");

			FileWriter fwrite = new FileWriter("C:\\Users\\苹果芒果火龙果\\Desktop\\Price.txt", true);

			Scanner sc = null;

			int count = 0;
			double sum = 0;
			sc = new Scanner(file);
			sc.useDelimiter("[^0123456789.]+");

			BufferedWriter fwriter = new BufferedWriter(fwrite);

			while (sc.hasNextDouble()) {
				double price = sc.nextDouble();
				count++;
				sum = sum + price;

				System.out.println(price);

			}
			double aver = sum / count;
			String str2 = String.format("%,3f", aver);
			System.out.println("           平均价格：" + str2+"\n");
			fwriter.write("平均价格："+str2);
			 fwriter.flush();
			fwriter.close();
		} catch (Exception exp) {
			System.out.println(exp);
		}
	}
}
